Tata Infotech Previous Years Solved Sample Placement Papers
-
Which keyword is used to create an instance of a class?
A: new
B: return
C: this
D: create
Ans: A -
Which keyword is used to inherit the properties and methods from another class?
A: import
B: package
C: extends
D: implements
Ans: C -
Which keyword is used to refer to the current instance of a class?
A: class
B: this
C: instance
D: object
Ans: B -
Which keyword in Java is used for importing packages into a program?
A: import
B: package
C: include
D: requires
Ans: A -
What is the purpose of the "super" keyword in Java?
A: To refer to the current object
B: To invoke the superclass constructor or methods
C: To create multiple instances of a class
D: To hide data and methods within a class
Ans: B -
What is the purpose of the "this" keyword in Java?
A: To refer to the superclass
B: To create multiple instances of a class
C: To hide data and methods within a class
D: To refer to the current object
Ans: D -
What is the purpose of the "final" keyword in Java?
A: To prevent the inheritance of a class
B: To prevent overriding of a method
C: To prevent modification of a variable's value
D: All of the above
Ans: D -
Which of the following can be used to create a custom checked exception?
A: Extending the Exception class
B: Extending the Error class
C: Extending the RuntimeException class
D: None of the above
Ans: A -
Which of these is an unchecked exception?
A: ClassNotFoundException
B: SQLException
C: IOException
D: ArithmeticException
Ans: D -
Which keyword is used to manually throw an exception in Java?
A: new
B: throw
C: throws
D: Throwable
Ans: B -
Which of these classes is the superclass of all Exception and Error classes?
A: Exception
B: Error
C: Throwable
D: Object
Ans: C -
What does the finally block do?
A: Catches any exception
B: Executes whether an exception is thrown or not
C: Executes only when an exception is thrown
D: Executes only when an exception is not thrown
Ans: B -
Which keyword in Java is used for constant variables?
A: const
B: static
C: constant
D: final
Ans: D -
In Java, what is the primary purpose of the Thread class?
A: File handling
B: String operations
C: Network operations
D: Creating and executing threads
Ans: D -
Which method is used to start the execution of a thread?
A: run()
B: start()
C: execute()
D: go()
Ans: B